package top.jiangyixin.cloud.ribbon.consumer.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * TODO
 * @version 1.0
 * @author jiangyixin
 * @date 2021/1/19 上午11:36
 */
@Service
public class HelloService {
	
	@Resource
	private RestTemplate restTemplate;
	
	@HystrixCommand(fallbackMethod = "helloServiceError")
	public String helloService() {
		return restTemplate.getForEntity(
				"http://HELLO-SERIVCE/hello", String.class).getBody();
	}
	public static String helloServiceError() {
		return "error";
	}
}
